<?php
/**
 * Created by PhpStorm OF Administrator.
 * User: YUYI
 * Date: 2018/7/12 0012
 * Time: 下午 5:29
 * Administrator
 */

namespace app\api\controller;


use app\common\model\UserEquipments;
use app\common\model\Users;

class User extends Base
{
    public function __call($name, $arguments)
    {
        // TODO: Implement __call() method.
        if (substr($name,0,6) == 'update'){
            call_user_func_array('update',array_merge(['name'=>substr($name,6)],$arguments));
        }
    }

    public function update()
    {
        $uid = input('user_id');
        $data = input();
        unset($data['user_id']);
        $user_head_img_url = input('user_head_img_url');
        if ($user_head_img_url) {
            $ue = UserEquipments::get(['equipment_id' => $uid]);
            trace($user_head_img_url);
            $r = $ue->save($data);
        }else{
            $r = $this->user->save($data);
        }
        if (!$r)
            return $this->errorInfo('info'.$uid);
        else{
            return $this->successInfo('成功修改用户头像');
        }
    }

    public function getUserGroup()
    {
        
    }
}